package cn.itsource.basic.intercepto;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;


    /**
     * 注册我自定义的拦截器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**") //拦截所有
                .excludePathPatterns("/login/**")//放行login登录 ，不拦截
                .excludePathPatterns("/verifyCode/**") //图形验证码+发短信
                //放行跟注册有关的
                .excludePathPatterns("/minio") //minio上传图片
                .excludePathPatterns("/user/register/**") //电话或者邮箱注册
                .excludePathPatterns("/fastDfs/**","/shop/settlement") //fastDfs上传图片 + 店铺入住
                .excludePathPatterns("/shop/exportExcel","/shop/importExcel","/log/exportFile") //导入导出
                .excludePathPatterns("/**/activation/**") //邮箱激活

                .excludePathPatterns("/swagger-resources/**") //下面4个都是swagger的放行
                .excludePathPatterns("/webjars/**")
                .excludePathPatterns("/v2/**")
                .excludePathPatterns("/swagger-ui.html/**")

        ;
    }
}
